<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="../plugins/layui/css/myPage.css">

</head>
<body  >
<div class="layui-container">


    <form class="layui-form">
        <div class="layui-row">
            <div class="layui-col-md12">

                <fieldset class="layui-elem-field" style="margin-top: 20px;">
                    <legend>新增办公室报账</legend>


                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label"><span style="color: red;">*</span>日期</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="riqi"  lay-verify="required" required   class="layui-input" id="riqi" >
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label"><span style="color: red;">*</span>名目</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="mingmu"  lay-verify="required" required   class="layui-input" id="mingmu" >
                            </div>
                        </div>


                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;"><span style="color: red;">*</span>金额</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="jine"  lay-verify="required" required   class="layui-input" id="jine" lay-filter = "jine">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label" style="width: 70px;"><span style="color: red;">*</span>报账人</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name="bzr"  lay-verify="required" required   class="layui-input" id="bzr" lay-filter = "bzr">
                            </div>
                        </div>



                    </div>

                    <div class="layui-form-item">





                        <div class="layui-inline">
                            <label class="layui-form-label">经手人</label>
                            <div class="layui-input-inline" style="width: 150px;">
                                <input   type="text" name=""   placeholder=""  class="layui-input layui-disabled" disabled id="jsr" >
                            </div>
                        </div>

                    </div>






                </fieldset>
            </div>
        </div>


        <button class="layui-btn layui-btn-normal"  lay-submit  lay-filter="new" style="width: 10%; position: absolute;left: 35%"  >立即提交</button>
        <button type="reset" class="layui-btn layui-btn-normal" style="width: 10%; position: absolute;left: 55%" >重置</button>
    </form>
</div>
<script src="../plugins/layui/layui.js"></script>
<script src="../js/config.js"></script>
<script src="../js/jquery.js"></script>
<script src="../js/jquery.md5.js"></script>
<script src="../js/tools.js"></script>

<script>
    layui.use(['table','form','layer','laydate','upload'],function () {
        var table = layui.table;
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var currentUser ;

        //校验


        judgments($,['mingmu','bzr','jsr'],/^[\u4E00-\u9FA5A-Za-z]+$/,"只能输入中文和英文");
        judgments($,["jine"],/^([1-9]\d*|0)(\.\d{1,2})?$/,"请输入整数或小数");


//日期控件渲染
        laydate.render({
            elem: '#riqi' //指定元素
            ,theme:'#0099FF'
            ,value: getFormatDate()
            ,type: 'date'
            ,format:'yyyy-MM-dd'
        });

        $.ajax({
            url: contextPath+"/currentUser",
            type: "GET",
            contentType:"application/json;charset=utf-8",
            dataType:"json",
            success: function(res) {
                currentUser = res.yhm;
                $("#jsr").val(currentUser);
            }
        });





        form.on('submit(new)', function(data){
            console.log(data.field);
            $("input").css("border","");
            $.ajax({
                url: contextPath+"/office",
                type: "POST",
                contentType:"application/json;charset=utf-8",
                data: JSON.stringify(data.field) ,
                dataType:"json",
                success: function(res) {
                    newSuccess($,layer,res)
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });

</script>
</body>
</html>